version: "3.8"

services:
  db:
    image: 'postgres:latest'
    container_name: manager-bd
    restart: on-failure
    networks:
      - manager-net
    ports:
      - "5432:5432"
    environment:
      - POSTGRES_DB=discordbot
      - POSTGRES_USER=${DB_USERNAME}
      - POSTGRES_PASSWORD=${DB_PASS}

  app:
    image: gypsyjr/discord-manager:0.1.0
    container_name: discord-manager
    build:
      context: .
    restart: on-failure
    networks:
      - manager-net
    depends_on:
      - db
    command: gradle bootRun
    environment:
      - DB_PASS=${DB_PASS}
      - DB_URL=jdbc:postgresql://manager-bd:5432/discordbot?useSSL=false
      - DB_USERNAME=${DB_USERNAME}
      - DISCORD_TOKEN=${DISCORD_TOKEN}
      - SEGMIND_TOKEN=${SEGMIND_TOKEN}

networks:
  manager-net:
    driver: bridge